package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.SwingUtilities;

import controlador.ControladorCompraProveedor;
import controlador.ControladorListadoProductosPorDeposito;


/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class VentanaListadoProductosPorDeposito extends javax.swing.JFrame {
	private JPanel panContenedor;
	private JLabel lblProductosDeposito;
	private JButton btnGenerar;
	private JLabel lblDeposito;
	private JComboBox cmbDeposito;
	private JScrollPane scpDeposito;
	private JTable tblListado;
	

	/**
	 * Auto-generated main method to display this JFrame
	 */
	
	public VentanaListadoProductosPorDeposito() {
		super();
		initGUI();
	}
	

	// Metodos de la vista limpiar combobox cargarlo con el arreglo buscar x codigo

	public void setDepositosComboBox(ArrayList<String> nombre){
		cmbDeposito.removeAllItems();
		cmbDeposito.addItem("Seleccione una opcion");
		for(int i = 0; i < nombre.size();i++)
			cmbDeposito.addItem(nombre.get(i));	
	}

	public String getCmbDepositoString(){
		return  cmbDeposito.getSelectedItem().toString();
	}
	
	public void agregarListener(ControladorListadoProductosPorDeposito accion){
		btnGenerar.addActionListener(accion);
	}

	/**********************************************************************************************/
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				panContenedor = new JPanel();
				getContentPane().add(panContenedor, "Center");
				panContenedor.setBounds(0, 0, 557, 373);
				panContenedor.setLayout(null);
				{
					lblProductosDeposito = new JLabel();
					panContenedor.add(lblProductosDeposito);
					lblProductosDeposito.setText("   Listado de Productos por Deposito");
					lblProductosDeposito.setBounds(76, 12, 400, 44);
					lblProductosDeposito.setFont(new java.awt.Font("Comic Sans MS",0,22));
					lblProductosDeposito.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				}
				{
					scpDeposito = new JScrollPane();
					panContenedor.add(scpDeposito);
					scpDeposito.setBounds(37, 112, 485, 239);
				}
				{
					ComboBoxModel cmbDepositoModel = 
							new DefaultComboBoxModel(
									new String[] { "Item One", "Item Two" });
					cmbDeposito = new JComboBox();
					panContenedor.add(cmbDeposito);
					cmbDeposito.setModel(cmbDepositoModel);
					cmbDeposito.setBounds(340, 75, 104, 23);
				}
				{
					lblDeposito = new JLabel();
					panContenedor.add(lblDeposito);
					lblDeposito.setText("Seleccione el Deposito:");
					lblDeposito.setBounds(208, 75, 146, 23);
				}
				{
					btnGenerar = new JButton();
					panContenedor.add(btnGenerar);
					btnGenerar.setText("Generar");
					btnGenerar.setBounds(456, 75, 61, 24);
				}
				tblListado = new JTable();
				scpDeposito.setViewportView(tblListado);
			}
			pack();
			this.setSize(573, 411);
		} catch (Exception e) {
			//add your error handling code here
			e.printStackTrace();
		}
	}

	public void setListado(AbstractTableModel abstractTableModel){
		tblListado.setModel(abstractTableModel);
	}

	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
}
